package com.pactera.miyuangroup.controller.web;

import com.pactera.miyuangroup.service.RoleMenuService;
import com.pactera.miyuangroup.vo.request.web.RoleMenuBindRequest;
import com.pactera.miyuangroup.vo.response.ResultModel;
import com.pactera.miyuangroup.vo.response.VoidResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *  角色菜单绑定
 */
@Api(description = "角色权限关系接口")
@RestController
@RequestMapping("roleMenu")
@Slf4j
public class RoleMenuController {

    @Autowired
    private RoleMenuService roleMenuService;

    @ApiOperation(value = "角色权限关系绑定", notes = "角色权限关系绑定")
    @RequestMapping(value = "/bind", method = RequestMethod.POST)
    public ResultModel<VoidResponse> roleBindMenu(@RequestBody RoleMenuBindRequest req) {

        boolean flg = roleMenuService.BindRoleMenu(req.getRoleId(), req.getMenuIds());
        if (!flg) {
            return ResultModel.fail();
        }
        return ResultModel.ok();
    }

}
